package com.mgq.java8.lambda;

import java.util.function.BiPredicate;
import java.util.function.IntPredicate;
import java.util.function.Predicate;

/**
 * <b>功能：</b>Predicate<br>
 * <b>Copyright mgq</b>
 * <li>版本&nbsp;&nbsp;&nbsp;&nbsp;修改日期&nbsp;&nbsp;&nbsp;&nbsp;部　　门&nbsp;&nbsp;&nbsp;&nbsp;作　者&nbsp;&nbsp;&nbsp;&nbsp;变更内容</li><hr>
 * <li>v1.0&nbsp;&nbsp;&nbsp;&nbsp;20220412&nbsp;&nbsp;营业后台&nbsp;&nbsp;&nbsp;&nbsp;马广奇&nbsp;&nbsp;&nbsp;&nbsp;创建类</li>
 * <br><br>
 *
 * @author 马广奇
 * @version 2022-04-12 20:34
 */
public class PredicateTest {

    public static void testPredicate() {
        Predicate<String> predicate = (String s) -> s.isEmpty();
        Predicate<String> predicate2 = String::isEmpty;
        BiPredicate<String, Long> biPredicate = (s, param) -> s.length() > 5 && param % 2 == 0;
        //java8提供了针对原始类型的predicate,如IntPredicate,LongPredicate,避免拆箱装箱性能损耗.
        IntPredicate intPredicate = i -> i > 0;

        System.out.println(predicate.test("hello world"));
        System.out.println(predicate2.test("hello world"));
        System.out.println(biPredicate.test("hello world", 20L));
        System.out.println(intPredicate.test(2));

    }

    public static void main(String[] args) {
        testPredicate();
    }
}
